package com.demo;

import com.spring.annotation.Component;
import com.web.ModelAndView;
import com.web.annotation.*;

import java.util.Map;

/**
 * @author chengjy
 * @date 2025/4/15
 */
@Component
@Controller
@RequestMapping("/hello")
@ResponseBody
public class HelloController {

    @RequestMapping("/hello")
    public String hello() {
        return "哈喽，本人来了！我是香菇大魔头！";
    }
    @RequestMapping("/user")
    public User user(@RequestParam("name") String name ,@RequestParam("age") Integer age) {
        return new User(name, age);
    }
    @RequestMapping("/view")
    public ModelAndView view(@RequestParam("name") String name , @RequestParam("age") Integer age) {
        ModelAndView modelAndView = new ModelAndView("index.html");
        modelAndView.setContext( Map.of("name",name,"age",age));
        return modelAndView;
    }
}
